#!/bin/bash -x

kata_coco_top_dir="$HOME/workspace/CoCo"

cosign_name="cosign-linux-amd64"
cosign_url="https://github.com/sigstore/cosign/releases/download/v2.2.1/cosign-linux-amd64"
cosign_cache="${kata_coco_top_dir}/${cosign_name}"
cosign_bin="/usr/local/bin/cosign"

if [ ! -e ${cosign_cache} ]; then
  wget -O ${cosign_cache} ${cosign_url}
  chmod +x ${cosign_cache}
fi

echo "[Link ${cosign_bin} -> ${cosign_cache}]"
sudo mkdir -p $(dirname ${cosign_bin}) || true
sudo ln -s ${cosign_cache} ${cosign_bin}

$(basename ${cosign_bin}) version
